﻿@page "/Demo_domtree_input_typing"

<p>
	A sample for how to use &lt;BlazorDomTree/&gt; to get the input value event it's not committed yet.
</p>

Type keyword to search :
<BlazorDomTree OnRootReady="bdtready" />
<div>@searchresult</div>

@code
{
	string searchresult;

	void bdtready(BlazorDomTree bdt)
	{

		PlusControl inp1 = bdt.Root.Create("input type='text' placeholder='search'");

		inp1.SetFocus(99);

		inp1.OnChanging(delegate
		{
			string kw = inp1.Value.Trim();
			if (kw.Length == 0)
			{
				searchresult = "Please type something..";
				BlazorSession.Current.Toast("", 0, "typinginfo");
			}
			else
			{
				searchresult = "No result for [" + kw + "]";
				BlazorSession.Current.Toast("Your are typing '" + kw + "'", 1000, "typinginfo");
			}
			StateHasChanged();
		});

		inp1.OnChange(delegate
		{
			searchresult = "Commit '" + inp1.Value + "'";
			BlazorSession.Current.Toast(searchresult, 1000, "typinginfo");
			StateHasChanged();
		});
	}
}
